<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>关闭进程文件指针</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pathinfo.html">« pathinfo</a></li>
      <li style="float: right;"><a href="function.popen.html">popen »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.filesystem.html">文件系统函数</a></li>
    <li>关闭进程文件指针</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pclose" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pclose</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pclose</span> &mdash; <span class="dc-title">关闭进程文件指针</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.pclose-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pclose</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$handle</code></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   关闭用 <span class="function"><a href="function.popen.html" class="function">popen()</a></span> 打开的指向管道的文件指针。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pclose-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">handle</code></dt>

     <dd>

      <p class="para">
       文件指针必须有效，且必须是成功调用 <span class="function"><a href="function.popen.html" class="function">popen()</a></span> 所返回的。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pclose-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回运行的进程的终止状态。发生错误时会返回 <code class="literal">-1</code>。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
 <p class="para">
  如果 PHP 是通过 --enable-sigchild 编译的，此函数将没有返回值。
 </p>
</p></blockquote>

 </div>


 <div class="refsect1 examples" id="refsect1-function.pclose-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2214">
    <p><strong>示例 #1 <span class="function"><strong>pclose()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$handle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">popen</span><span style="color: #007700">(</span><span style="color: #DD0000">'/bin/ls'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">pclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.pclose-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <strong>仅限 Unix</strong><br />
   <p class="para">
    <span class="function"><strong>pclose()</strong></span> 在内部使用 <code class="literal">waitpid(3)</code>
    系统调用实现的。要获得真正的退出状态码，应该使用 <span class="function"><a href="function.pcntl-wexitstatus.html" class="function">pcntl_wexitstatus()</a></span> 函数。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pclose-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.popen.html" class="function" rel="rdfs-seeAlso">popen()</a> - 打开进程文件指针</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>